package com.twu.biblioteca;

public class Book {

    private String title;
    private String author;
    private Boolean available;

    public Book(String title, String author, Boolean available) {
        this.title = title;
        this.author = author;
        this.available = available;
    }

    boolean checkIfAvailable() {
        return this.getAvailable();
    }

    public void reserve() throws BookUnavailableException {
        if (this.checkIfAvailable()) {
            this.setAvailable(false);
        } else {
            throw new BookUnavailableException();
        }
    }

    public String getTitle() {
        return title;
    }

    public String getAuthor() {
        return author;
    }

    public Boolean getAvailable() {
        return available;
    }

    void setAvailable(Boolean available) {
        this.available = available;
    }

}
